#include "add.h"
#include "ui_add.h"
#include <QPainter>
extern LinkList<Node>stu;
add::add(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::add)
{
    ui->setupUi(this);
    setWindowTitle("添加学生信息");
}

add::~add()
{
    delete ui;
}

void add::on_add_ok_button_clicked()//点击确定后将添加的学生信息存入链表
{
    QString name = this->ui->add_name->text();
    QString id = this->ui->add_number->text();
    QString roomnu = this->ui->add_name_2->text();
    QString classnu = this->ui->add_name_3->text();
    QString sex=NULL;
    if(this->ui->add_button1->isChecked())
    {
     sex = this->ui->add_button1->text();
    }
    if(this->ui->add_button2->isChecked())
    {
     sex = this->ui->add_button2->text();
    }
    QString faculty=this->ui->add_faculty->currentText();
    if(name==NULL||id==NULL||sex==NULL||faculty==NULL)
    {
        QMessageBox::warning(this,"警告","信息未完善");
        return;
    }
    Node a(id,name,sex,faculty,roomnu,classnu);
    stu.Insert(1,a);
     QMessageBox::warning(this,"提示","添加成功");
}

void add::on_add_cancel_button_clicked()
{
    mainWindow*mWin=new mainWindow;
    mWin->show();
    delete this;
}
void add::paintEvent(QPaintEvent *)
{
   QPainter p(this);//创建画家对象p
    //绘图操作
    p.drawPixmap(rect(),QPixmap("../pic/beffc781ly1gt3fx3ih1tj20no0hswh7.jpg"));

}
